<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('要素项列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <form id="formId">
            <input type="hidden" name="groupId" id="groupId" th:value="${groupId}" readonly/>
        </form>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()" shiro:hasPermission="rule:groupDetail:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="rule:groupDetail:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('rule:groupDetail:edit')}]];
    var removeFlag = [[${@permission.hasPermi('rule:groupDetail:remove')}]];
    var prefix = ctx + "rule/groupDetail";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "风控策略组明细",
            id: "bootstrap-table",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'groupId',
                    title: '规则组ID',
                    visible: false
                },
                {
                    field: 'groupName',
                    title: '规则组名称'
                },
                {
                    field: 'elementsName',
                    title: '要素项名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function add() {
        var groupId = $("#groupId").val();
        var url = prefix + '/add/' + groupId;
        $.modal.open("选择要素项", url);
    }


    function submitHandler(index, layero) {
        $.modal.close();
    }
</script>
</body>
</html>